# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# Name:         testcacl
# Description:  
# Author:       Administrator
# Date:         2020/2/12
#-------------------------------------------------------------------------------

import unittest

# 如果要使用TestCase中的相关内容，则需要进行继承
from guitest.unitdemo.cacl import Cacl
from parameterized import parameterized

div_data = [(10, 2, 5), (10, 3, 3), (10, 0, 0)]

class CaclTest(unittest.TestCase):

	@classmethod
	def setUpClass(cls):
		pass
		# print('***setUpClass*')
	# 该方法一般是用于完成在执行测试用例前的准备工作
	def setUp(self):
		pass
		# print('**setUp**')

	# 加法的测试方法.必须使用test开始
	def test_add(self):
		# 准备测试数据100,200,300
		c = Cacl(100,200)
		add_result = c.add()
		# testcase提供的断言方法
		self.assertEqual(add_result,300)

	# 减法的测试方法
	def test_sub(self):
		c = Cacl(200,100)
		sub_result = c.sub()
		self.assertEqual(sub_result,50)

	# 乘法的测试方法
	# @unittest.skipUnless(3>5,'不执行')
	def test_mul(self):
		c = Cacl(2,3)
		mul_result = c.mul()
		self.assertEqual(mul_result,6)

	# 除法的测试方法
	# [(10,2,5),(10,3,3),(10,0,0)]
	@parameterized.expand(div_data)
	def test_div(self,x,y,expect):
		c = Cacl(x,y)
		div_actual = c.div()
		self.assertEqual(div_actual,expect)

	# 该方法一般是用于完成在执行测试用例前的收尾工作
	def tearDown(self):
		pass
		# print('**tearDown**')

	@classmethod
	def tearDownClass(cls):
		pass
		# print('**tearDownClass**')

if __name__ == '__main__':

    unittest.main(verbosity=2)

